package com.flexrrb.effects
{
	import mx.effects.effectClasses.TweenEffectInstance;
	import mx.core.mx_internal;
	
	public class ScaleEffectInstance extends TweenEffectInstance
	{
		public var scaleXTo:Number;
		public var scaleYTo:Number;
		
		public var originalScaleX:Number;
		public var originalScaleY:Number;
		
		public function ScaleEffectInstance(target:Object)
		{
			super(target);
		}
		
		override public function play():void
		{
			super.play();
			
			originalScaleX = target.scaleX;
			originalScaleY = target.scaleY;
			
			tween = createTween(this, [originalScaleX, originalScaleY], 
					[scaleXTo, scaleYTo], duration);
		}
		
		override public function onTweenUpdate(value:Object):void
		{
			target.scaleX = value[0];
			target.scaleY = value[0];
		}
		
		
		override public function reverse():void
		{
			super.reverse();
			tween = createTween(this, [scaleXTo, scaleYTo], 
					[originalScaleX, originalScaleY], duration);
		}
	}
}